//
// Created by Administrator on 2016/9/6.
//

#ifndef ZAINTL_PKGUTIL_H
#define ZAINTL_PKGUTIL_H

#include "File.h"

namespace ZainTL{
    enum FileType {
        txt,
        img,
        model,
        audio
    };

    struct FileDatas {
        FileType fileType;
        char *path;
        char *data;
        uint64_t dataLen;
    };

class PKGUtil {
private:
    std::string mEncryptionKey="default";
    void pkgImpl(ZainTL::File *inFile, ZainTL::File *outFile, bool bEncrypt);

public:
    std::string pkg(const char *path, const char *outputPath = NULL, bool bEncrypt= false);

    void unpkg(const char *path, std::function<void(FileDatas &)> onFileData, bool bDecrypt=false);

    void setEncryptionKey(const char *key);

    void encrypt(const char *origin, uint64_t count, std::function<void(char *)> onEncrypted);

    void decrypt(const char *origin, uint64_t count, std::function<void(char *)> onDecrypted);

    FileType getFileType(std::string &basic_string);
};

}

#endif //ZAINTL_PKGUTIL_H
